package cn.lds.healthj377.dto;

import lombok.Data;

@Data
public class Pager {

    /**
     * 每页多少提奥
     */
    private Integer pageSize = 4;

    /**
     * 一共有多少条
     */
    private Integer totalRow;

    /**
     * 一共有多少页
     */
    private Integer totalPage;

    /**
     * 当前有多少页
     */
    private Integer pageIndex = 1;


    public Integer getTotalPage() {

        totalPage = totalRow % pageSize == 0 ? totalRow / pageSize : totalRow / pageSize + 1;

        return totalPage;
    }

    /**
     * 返回查询时开始的条数
     * @return
     */
    public Integer getStartIndex(){
        return (pageIndex-1) * pageSize;
    }

    @Override
    public String toString() {
        return "Pager{" +
                "pageSize=" + pageSize +
                ", totalRow=" + totalRow +
                ", totalPage=" + totalPage +
                ", pageIndex=" + pageIndex +
                '}';
    }
}
